package com.carsystem.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.carsystem.entity.Carsetmeal;
import com.carsystem.mapper.CarsetmealMapper;
import com.carsystem.service.ICarsetmealService;
import com.carsystem.utils.PageResult;
import com.carsystem.utils.QueryPageBean;
import org.apache.commons.lang3.StringUtils;
import org.apache.dubbo.config.annotation.Service;

import javax.annotation.Resource;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author ykl
 * @since 2021-12-04
 */
@Service
public class CarsetmealServiceImpl extends ServiceImpl<CarsetmealMapper, Carsetmeal> implements ICarsetmealService {

    @Resource
    private CarsetmealMapper carsetmealMapper;


    @Override
    public PageResult findPage(QueryPageBean queryPageBean) {
        Page<Carsetmeal> carsetmealPage = new Page<>(queryPageBean.getCurrentPage(),queryPageBean.getPageSize());
        QueryWrapper<Carsetmeal> queryWrapper = new QueryWrapper<>();
        if (StringUtils.isNotBlank(queryPageBean.getQueryString())){
            queryWrapper.like("name",queryPageBean.getQueryString());
        }
        Page<Carsetmeal> page = carsetmealMapper.selectPage(carsetmealPage, queryWrapper);
        PageResult pageResult = new PageResult(page.getTotal(), page.getRecords());
        return pageResult;
    }
}
